package com.ruoyi.http.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.date.DateFormater;
import com.ruoyi.http.domain.WeChat00800T;
import com.ruoyi.http.service.IWeChatTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/http/weChat00800")
public class WeChat00800 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;
    @PostMapping("/weChat")
    public AjaxResult http(WeChat00800T weChat00800T) {
        List<WeChat00800T> weChat = new ArrayList<WeChat00800T>();
        WeChat00800T weChatVO = new WeChat00800T();
        WeChat00800T weChatVo = new WeChat00800T();
        weChatVO = weChatTService.getCompanyInfoByProject(weChat00800T);
        weChatVO.setPrice(weChat00800T.getPrice());
        weChatVO.setUsercode(weChat00800T.getUsercode());
        weChatVO.setProjectid(weChat00800T.getProjectid());
        weChatVo = weChatTService.getPriceByCompany(weChatVO);
        if(weChatVo == null){
            weChatTService.insertPriceForCompany(weChatVO);
        }else{
            weChatVo.setPrice(weChat00800T.getPrice());
            weChatVo.setPriceid(weChatVo.getPriceid());
            weChatVo.setCreatedate(DateFormater.getSystemCurrentDateSimple());
            weChatTService.updatePriceForCompany(weChatVo);
        }
        return AjaxResult.success(weChat);
    }
}